package com.sf.algo.shortpath;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.junit.Test;

public class ShortPathAlgoTest {
	/*@Test
	public void testShortPath() {
		int [][] maps = {
				//0  1  2  3  4  5  6  7  8  9  10 11
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },//0
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },//1
                { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 },//2
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },//3
                { 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0 },//4
                { 0, 0, 0, 0, 0, 0, 0 ,0, 1, 0, 0, 0 },//5
                { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },//6
                { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },//7
                { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },//8
                { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },//9
                { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0 },//10
                { 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0 },//11
                };
		
		int [][] newMap = MapUtil.getBarMap();
		Node start = new Node(5,6);
		Node end = new Node(6,2);
		MapInfo mapInfo = new MapInfo(start, end);
		ShortPathAlgo shortPath = ShortPathAlgo.getInstance();
		StartEndResult result = shortPath.start(mapInfo);
		if(result != null) {
			System.out.println("所消耗的分值为："+result.getConsumerScore());
			List<Coord> path = result.getPath();
			Collections.reverse(path);
			for(Coord coord : path) {
				System.out.println("x = "+coord.getX() + " y = " + coord.getY());
			}
		}
		printMap(newMap);
	}*/
	private void printMap(int[][] maps) {
		System.out.println("-------------------------------");
		for (int i = 0; i < maps.length; i++)
		{
			for (int j = 0; j < maps[i].length; j++)
			{
				System.out.print(maps[i][j] + " ");
			}
			System.out.println();
		}
	}
	
	@Test
	public void testShortPath2(){
		List<Coord> list = new ArrayList<>();
		list.add(new Coord(5,6));
		//list.add(new Coord(6,2));
		list.add(new Coord(8,3));
		//list.add(new Coord(9,3));
		BatchCoordProcessor processor = new BatchCoordProcessor(list,MapUtil.getBar());
		List<StartEndResult> process = processor.process();
		process.forEach(result -> {
			System.out.println("始发网点:"+ result.getStart()+ "到目的网点:" + result.getEnd()+" 所消耗的值为"+result.getConsumerScore()+"，路径为：");
			result.getPath().forEach(c -> {
				System.out.println(c.toString());
			});
		});
		
	}
}
